package com.googlecode.horncomb.bean.paged;

import com.googlecode.horncomb.bean.filter.ConditionSet;
import com.googlecode.horncomb.bean.order.Order;
import com.googlecode.horncomb.bean.paged.PagedSetting;

public class DefaultPagedSetting implements PagedSetting {
	private String name = null;
	private int page = PagedSetting.DEFAULT_PAGE;
	private int pageSize = PagedSetting.DEFAULT_PAGE_SIZE;
	private int maxLinkedPages = PagedSetting.DEFAULT_MAX_LINKED_PAGES;
	private Order order;
	private ConditionSet conditionSet;

	public DefaultPagedSetting() {
		super();
	}

	public DefaultPagedSetting(String name) {
		super();
		this.name = name;
	}

	public DefaultPagedSetting(int page, int pageSize) {
		super();
		this.page = page;
		this.pageSize = pageSize;
	}

	public DefaultPagedSetting(int page, int pageSize, int maxLinkedPages) {
		super();
		this.page = page;
		this.pageSize = pageSize;
		this.maxLinkedPages = maxLinkedPages;
	}

	public DefaultPagedSetting(ConditionSet constraints, Order order) {
		super();
		this.order = order;
		this.conditionSet = constraints;
	}

	public DefaultPagedSetting(int page, int pageSize, int maxLinkedPages,
			ConditionSet constraints, Order order) {
		super();
		this.page = page;
		this.pageSize = pageSize;
		this.maxLinkedPages = maxLinkedPages;
		this.order = order;
		this.conditionSet = constraints;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the page
	 */
	public int getPage() {
		return page;
	}

	/**
	 * @param page
	 *            the page to set
	 */
	public void setPage(int page) {
		if (page < 1) {
			page = 1;
		}
		if (page != this.page) {
			this.page = page;
		}
	}

	/**
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}

	/**
	 * @param pageSize
	 *            the pageSize to set
	 */
	public void setPageSize(int pageSize) {
		if (pageSize < 1) {
			pageSize = 1;
		}
		if (pageSize != this.pageSize) {
			this.pageSize = pageSize;
		}
	}

	/**
	 * @return the order
	 */
	public Order getOrder() {
		return order;
	}

	/**
	 * @param order
	 *            the order to set
	 */
	public void setOrder(Order order) {
		this.order = order;
	}

	/**
	 * @return the conditionSet
	 */
	public ConditionSet getConditionSet() {
		return conditionSet;
	}

	/**
	 * @param conditionSet
	 *            the conditionSet to set
	 */
	public void setConditionSet(ConditionSet constraints) {
		this.conditionSet = constraints;
	}

	/**
	 * @return the maxLinkedPages
	 */
	public int getMaxLinkedPages() {
		return maxLinkedPages;
	}

	/**
	 * @param maxLinkedPages
	 *            the maxLinkedPages to set
	 */
	public void setMaxLinkedPages(int maxLinkedPages) {
		this.maxLinkedPages = maxLinkedPages;
	}

}
